package com.base.mine.adapter;

import android.content.Context;
import android.view.LayoutInflater;
import android.view.View;
import android.view.ViewGroup;
import android.widget.BaseAdapter;
import android.widget.Button;
import android.widget.TextView;

import com.base.mine.R;
import com.base.mine.bean.AccountPwdBean;

import java.util.List;

public class AccountAdapter extends BaseAdapter {
    private List<AccountPwdBean> accountPwdBeanList;
    private Context context;

    public AccountAdapter(List<AccountPwdBean> accountPwdBeanList, Context context) {
        this.accountPwdBeanList = accountPwdBeanList;
        this.context = context;
    }

    @Override
    public int getCount() {
        return accountPwdBeanList.size();
    }

    @Override
    public Object getItem(int position) {
        return accountPwdBeanList == null ? null : accountPwdBeanList.get(position);
    }

    @Override
    public long getItemId(int position) {
        return position;
    }

    @Override
    public View getView(int position, View convertView, ViewGroup parent) {
        ViewHolder viewHolder=null;
        if (convertView==null) {
            viewHolder = new ViewHolder();
            convertView= LayoutInflater.from(context).inflate(R.layout.item_account_list,null);
            viewHolder.account= (TextView) convertView.findViewById(R.id.account);
            convertView.setTag(viewHolder);
        }else {
            viewHolder= (ViewHolder) convertView.getTag();
        }
        viewHolder.account.setText(accountPwdBeanList.get(position).getAccount());
        return convertView;
    }


    class ViewHolder{
        TextView account;
    }

}
